Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies: Upgrade @joshwooding/vite-plugin-react-docgen-typescript #28615

Conversation

brendo
Copy link

@brendo brendo commented Jul 16, 2024

What I did

This PR bumps the @joshwooding/vite-plugin-react-docgen-typescript in the react-vite.

This main desire behind this change is to get joshwooding/vite-plugin-react-docgen-typescript#35 which removes a dependency on glob-promise and raises the minimum version of glob from 7 to 10.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 76.3 MB 76.3 MB 331 B -0.38 0%
initSize 169 MB 183 MB 14.4 MB 444.16 🔺7.9%
diffSize 92.8 MB 107 MB 14.4 MB 266.66 🔺13.5%
buildSize 7.46 MB 7.46 MB 91 B 1.15 0%
buildSbAddonsSize 1.62 MB 1.62 MB 0 B 1.2 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.3 MB 48 B 1.52 0%
buildSbPreviewSize 351 kB 351 kB 0 B 0.99 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.46 MB 4.46 MB 48 B 1.16 0%
buildPreviewSize 3 MB 3 MB 43 B 1.04 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 25.7s 15.2s -10s -525ms -0.14 -69%
generateTime 19.3s 22s 2.7s 1.33 🔺12.3%
initTime 18.2s 19.1s 849ms 1.09 4.4%
buildTime 12.1s 15.1s 2.9s 2.09 🔺19.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 7.1s 7.1s 85ms -0.3 1.2%
devManagerResponsive 4.6s 4.8s 186ms -0.07 3.8%
devManagerHeaderVisible 710ms 871ms 161ms 0.54 18.5%
devManagerIndexVisible 742ms 905ms 163ms 0.48 18%
devStoryVisibleUncached 1.2s 1.2s -29ms -0.5 -2.4%
devStoryVisible 743ms 906ms 163ms 0.49 18%
devAutodocsVisible 625ms 755ms 130ms 0.11 17.2%
devMDXVisible 648ms 740ms 92ms 0.09 12.4%
buildManagerHeaderVisible 676ms 735ms 59ms -0.14 8%
buildManagerIndexVisible 681ms 742ms 61ms -0.12 8.2%
buildStoryVisible 753ms 817ms 64ms 0.04 7.8%
buildAutodocsVisible 697ms 718ms 21ms 0.14 2.9%
buildMDXVisible 674ms 770ms 96ms 1.66 🔺12.5%

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

  • Updated @joshwooding/vite-plugin-react-docgen-typescript to ^0.4.0 in code/frameworks/react-vite/package.json
  • Removed dependency on glob-promise
  • Increased minimum version of glob from 7 to 10

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@brendo brendo force-pushed the chore_bump-vite-plugin-react-docgen-typescript branch from 5ef4d21 to c0e7ba4 Compare July 19, 2024 04:14
@brendo brendo force-pushed the chore_bump-vite-plugin-react-docgen-typescript branch from c0e7ba4 to 2652930 Compare July 22, 2024 00:39
@kasperpeulen kasperpeulen added maintenance User-facing maintenance tasks ci:normal labels Jul 22, 2024
@ndelangen ndelangen added dependencies and removed maintenance User-facing maintenance tasks labels Jul 25, 2024
@ndelangen ndelangen changed the title Bump @joshwooding/vite-plugin-react-docgen-typescript in react-vite Dependencies: UPgrade @joshwooding/vite-plugin-react-docgen-typescript Jul 25, 2024
@ndelangen ndelangen changed the title Dependencies: UPgrade @joshwooding/vite-plugin-react-docgen-typescript Dependencies: Upgrade @joshwooding/vite-plugin-react-docgen-typescript Jul 25, 2024
Copy link

nx-cloud bot commented Jul 25, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit bfc79a7. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@ndelangen ndelangen requested a review from shilman July 25, 2024 13:55
@brendo
Copy link
Author

brendo commented Aug 18, 2024

👋 Do you need anything from me to push this through?

@shilman
Copy link
Member

shilman commented Aug 19, 2024

Thanks for your contribution and for your patience @brendo ! Will try to merge/release today 🙏

@shilman
Copy link
Member

shilman commented Aug 20, 2024

@brendo FYI, we're seeing a perf issue on our unit tests and also a dramatically increased install size. We'll need to resolve those before we can merge.

@JReinhold
Copy link
Contributor

The new version of @joshwooding/vite-plugin-react-docgen-typescript does grow in size, purely because glob does. I don't understand how that would lead to a 14 MB increase though

v0.3.1 v0.4.0
image image
image image

@brendo
Copy link
Author

brendo commented Aug 20, 2024

Oh that's really quite unfortunate. From poking at glob, it looks like jackspeak is used to power the bin and not for runtime operation. Would this mean it's tree-shaken away in typical apps?

@JReinhold
Copy link
Contributor

Would this mean it's tree-shaken away in typical apps?

Good catch! Yes I'd expect that to treeshake. This is also evident by the size changes above, where the build size doesn't change, only the "install dependencies" size.

@ndelangen is anything stopping us from prebundling @joshwooding/vite-plugin-react-docgen-typescript, to circumven the transitive dependency of jackspeak (@joshwooding/vite-plugin-react-docgen-typescript -> glob@^10 > jackspeak.

@brendo you can try by just moving @joshwooding/vite-plugin-react-docgen-typescript to devDependencies, this should prebundle it instead and then we can see the numbers. Then we just need to test that it still works.

@ndelangen
Copy link
Member

@ndelangen is anything stopping us from prebundling @joshwooding/vite-plugin-react-docgen-typescript, to circumven the transitive dependency of jackspeak (@joshwooding/vite-plugin-react-docgen-typescript -> glob@^10 > jackspeak.

It's not possible for me to say if it's possible without looking at the code of @joshwooding/vite-plugin-react-docgen-typescript.

If the runtime spawns a subprocess that's from it's own package; then it cannot.
If the runtime spawns a subprocess that's from another package, that package has to be added as a regular dep.
If the runtime tries to load a file relative to the runtime.
if the runtime tries to resolve something relative to the runtime.

Basically:
If @joshwooding/vite-plugin-react-docgen-typescript makes a runtime reference to itself or another package, that isn't a normal import bundlers can deal with, then you can't prebundle it.

That would include things such as:

  • require.resolve('@joshwooding/vite-plugin-react-docgen-typescript/transformer')
  • fs.readFile(__dirname + '/file.json')

Those code section, the bundler would leave untouched, but then their behavior most certainly not function as intended.

@JReinhold
Copy link
Contributor

@brendo if prebundling doesn't work for some reason (it throws errors at runtime), alternatively you can try to just prebundle @joshwooding/vite-plugin-react-docgen-typescript by moving it to devDependencies, but not prebundle react-docgen-typescript where the magic happens, by adding that as an explicit dependencies.

@brendo
Copy link
Author

brendo commented Aug 21, 2024

So taking a closer look at the plugin, can we move it to a peerDependency? This package is conditional on if the user has configured the reactDocgen option to be react-docgen-typescript:

if (reactDocgenOption === 'react-docgen-typescript' && typescriptPresent) {
plugins.push(
require('@joshwooding/vite-plugin-react-docgen-typescript')({
...reactDocgenTypescriptOptions,
// We *need* this set so that RDT returns default values in the same format as react-docgen
savePropValueAsString: true,
})
);
}

By default, this option appears to be react-docgen, which means the package won't be used:

type TypescriptOptions = TypescriptOptionsBase & {
/**
* Sets the type of Docgen when working with React and TypeScript
*
* @default `'react-docgen'`
*/
reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
/** Configures `@joshwooding/vite-plugin-react-docgen-typescript` */
reactDocgenTypescriptOptions: Parameters<typeof docgenTypescript>[0];
};

It is reasonable to ask a user to install the package themselves instead of distributing it as part of @storybook/react-vite if they'd like to use the react-docgen-typescript option? Having that said, I noticed this option isn't documented so it'd be interesting to know how many users are specifying it. Nevermind, found via here and here.

@JReinhold
Copy link
Contributor

JReinhold commented Aug 22, 2024

I'm conflicted, ease of use vs package size.
@shilman thoughts on 👆?

(Moving it to a peer dep would be a breaking change in a major release, btw)

@xfournet
Copy link

xfournet commented Dec 2, 2024

It can be closed because #29724 has been merged

@brendo brendo closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants